# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qtsensors
pkgver=5.15.10_git20230424
pkgrel=0
_module="${pkgname#qt5-}"
_pkgver=45c04582b15a9bb4be01ae99aa7fda1bbba7d0df
_fullname=$_module-$_pkgver
pkgdesc="+The Qt Sensors API provides access to sensor hardware via QML and C++"
url="https://www.qt.io/developers/"
arch="all !armhf" # armhf blocked by qt5-qtdeclarative
license="LGPL-2.1-only AND LGPL-3.0-only AND GPL-3.0-only AND Qt-GPL-exception-1.0"
makedepends="
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	"
subpackages="$pkgname-dev"
options="!check" # No tests

source="https://dev.alpinelinux.org/archive/qt/$_fullname.tar.xz
	0001-Add-heart-rate-monitor-sensor-with-sensorfw-backend.patch
	0002-QHrmSensor-Make-the-usage-of-Status-enum-explicit-fo.patch
	0003-SensorfwHrmSensor-Don-t-force-a-data-rate-HRM-doesn-.patch
	0004-Adapt-to-unified-HeartRateChanged-signals-in-sensorf.patch
	0005-removes-characters-at-line-start-of-HRM-register.patch
	0006-Add-step-counter-sensor-with-sensorfw-backend.patch
	"
builddir="$srcdir/$_fullname"

_disturl="dev.alpinelinux.org:/archive/qt/"
snapshot() {
	clean
	makedepends="git xz rsync tar" deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone --filter=tree:0 https://invent.kde.org/qt/qt/$_module.git .
	git archive --format tar --prefix=$_fullname/ $_pkgver > "$SRCDEST"/$_fullname.tar
	xz -vv -T0 -9 -e "$SRCDEST"/$_fullname.tar
	rsync --progress -La "$SRCDEST"/$_fullname.tar.xz $_disturl
}

prepare() {
	default_prepare

	# We need to make the build system think we're running in a git repository
	# so it correctly symlinks during the build
	mkdir .git
}

build() {
	qmake-qt5
	make
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	# Drop QMAKE_PRL_BUILD_DIR because reference the build dir
	find "$pkgdir/usr/lib" -type f -name '*.prl' \
		-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

	install -d "$pkgdir"/usr/share/licenses
	ln -s /usr/share/licenses/qt5-base "$pkgdir"/usr/share/licenses/$pkgname
}

sha512sums="
4714431ab0bd8ae594452a39558635ed6257210ac668892d537b68f459522ae98f04543912368b3e9d6fe239a71d3a9366c7030cf0fbe2c12cc555db981f6734  qtsensors-45c04582b15a9bb4be01ae99aa7fda1bbba7d0df.tar.xz
ae090a5f976770638f1a261e5a9b85800386dec73a1ed16a371d6e96c34cfe8805492c4c4ec270de1de4d21e851869c637adc1cc05723ed9b1d9167125329289  0001-Add-heart-rate-monitor-sensor-with-sensorfw-backend.patch
e422e2aafda06b7ef8d507931297a59019d25060468c83a67771639f8d56ec99e72ada5c5c3c6ce3d101e073dbc3ded36cd2661a54a056be54156df32e119191  0002-QHrmSensor-Make-the-usage-of-Status-enum-explicit-fo.patch
2b5205ea81b9254fa1828811c7e4e0adaa1f89a39b6881cd2fec5d39d79064366871cba2adccdce1819ac7dd92dcfad0f96a558caa277aa81ced24a52dabc07a  0003-SensorfwHrmSensor-Don-t-force-a-data-rate-HRM-doesn-.patch
f06e469a6b550f6ce70450c2154dbdcecf663f205ea481e18c43d2370cc745941689f6a4e36efca5858ccf89116e532d20183f3fe64c67f3005f50beaa942075  0004-Adapt-to-unified-HeartRateChanged-signals-in-sensorf.patch
aa05566bd3bddeb5fc18cbd221aa9f86320fd80389b4a54a768d6235bff6a3d5734bf6eb18ac979b2aefb49aadbc62ba4aba3edd232b1593b77782a9badea91d  0005-removes-characters-at-line-start-of-HRM-register.patch
3d2b54bc1d4747dff3dd0baf1b4a823d3acab6754514da97029557bb8f9355b301ea5c4d7e163a747e7c01dc902ef4c3c29b1a001b664a8e02971be83dac187c  0006-Add-step-counter-sensor-with-sensorfw-backend.patch
"
